﻿using Dapper;
using Domain.IRepositorys.Base_Manage;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EFCore.Repositorys.Base_Manage
{
    public class DJBHRepository : IDJBHRepository
    {
        /// <summary>
        /// 根据编号生成规则返回单据编号
        /// </summary>
        /// <param name="en_code"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public string DJBH(int en_code)
        {
            using (SqlConnection sc = new SqlConnection("Data Source=121.37.93.71;Initial Catalog=CSSL_FL_WMS;User ID=sa;Password=geili@2025;Connect Timeout=30;Encrypt=True;TrustServerCertificate=True;"))
            {
                string sql = "exec [dbo].[dh] @code, @danhao out";
                DynamicParameters dynamicParameters = new DynamicParameters();
                dynamicParameters.Add("@code", en_code);
                dynamicParameters.Add("@danhao", direction: ParameterDirection.Output, dbType: DbType.String, size: 50);

                string bh = sc.Query<string>(sql, dynamicParameters).ToString();
                return dynamicParameters.Get<string>("danhao");
            }
        }
    }
}
